package com.recycle.common.enums;

import java.util.LinkedList;
import java.util.List;

public enum Recyclable {
    PAPER("可回收物-废纸", 5),
    PLASTIC("可回收物-塑料", 6),
    GLASS("可回收物-玻璃", 7),
    METAL("可回收物-金属", 8),
    CLOTH("可回收物-布料", 9);

    private final String label;
    private final long value;

    Recyclable(String label, int value) {
        this.label = label;
        this.value = value;
    }

    public String getLabel() {
        return label;
    }

    public long getValue() {
        return value;
    }

    public static String findLabel(long value) {
        for (Recyclable r : values()) {
            if (r.value==value) {
                return r.label;
            }
        }
        return null;
    }

    public static long findValue(String label) {
        for (Recyclable r : values()) {
            if (r.label.equals(label)) {
                return r.value;
            }
        }
        return 0L;
    }

    public static List<Long> valuesList() {
        List<Long> list = new LinkedList<>();
        for (Recyclable r : values()) {
            list.add(r.value);
        }
        return list;
    }
}
